package com.github.chirspan.xaas.log;

import cn.hutool.extra.spring.EnableSpringUtil;
import com.github.chirspan.xaas.log.aspect.ApiLogAspect;
import com.github.chirspan.xaas.log.event.ApiLogListener;
import com.github.chirspan.xaas.log.feign.ILogClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 *
 * @author chenpan
 */
@EnableAsync
@ConditionalOnWebApplication
@Configuration(proxyBeanMethods = false)
@EnableFeignClients
@EnableSpringUtil
public class LogAutoConfiguration {

    @Autowired
    ILogClient logClient;

    @Bean
    public ApiLogListener sysLogListener() {
        return new ApiLogListener(logClient);
    }

    @Bean
    public ApiLogAspect apiLogAspect() {
        return new ApiLogAspect();
    }
}
